package com.zkthink.ceres.promotion.entity;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.zkthink.base.entity.Entity;
import com.zkthink.ceres.promotion.dto.SalesLevelRuleDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

/**
 * <p>
 * 实体类 分销员
 * </p>
 *
 * @author kellen
 * @since 2020-08-22
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "ceres_sales_level",autoResultMap = true)
@ApiModel(value = "SalesLevel", description = "分销员")
@AllArgsConstructor
public class SalesLevel extends Entity<Long> {

  private static final long serialVersionUID = 1L;

  /**
   * 规则
   */
  @ApiModelProperty(value = "规则")
  @TableField(value = "rule", typeHandler = FastjsonTypeHandler.class)
  @Excel(name = "规则")
  private SalesLevelRuleDTO rule;

  /**
   * 间接分佣比例
   */
  @ApiModelProperty(value = "间接分佣比例")
  @NotNull(message = "间接分佣比例不能为空")
  @TableField("indirect_rate")
  @Excel(name = "间接分佣比例")
  private BigDecimal indirectRate;

  /**
   * 直接分佣比例
   */
  @ApiModelProperty(value = "直接分佣比例")
  @NotNull(message = "直接分佣比例不能为空")
  @TableField("direct_rate")
  @Excel(name = "直接分佣比例")
  private BigDecimal directRate;

  /**
   * 是否默认 1是 2否
   */
  @ApiModelProperty(value = "是否默认 1是 2否")
  @NotNull(message = "是否默认 1是 2否不能为空")
  @TableField("is_default")
  @Excel(name = "是否默认 1是 2否")
  private Integer isDefault;

  /**
   * 等级排序，等级小的排序就小
   */
  @ApiModelProperty(value = "等级排序，等级小的排序就小")
  @NotNull(message = "等级排序不能为空")
  @TableField("sort")
  @Excel(name = "等级排序，等级小的排序就小")
  private Integer sort;

  /**
   * 等级名称
   */
  @ApiModelProperty(value = "等级名称")
  @NotEmpty(message = "等级名称不能为空")
  @Length(max = 32, message = "等级名称长度不能超过32")
  @TableField(value = "level_name", condition = LIKE)
  @Excel(name = "等级名称")
  private String levelName;

  /**
   * 逻辑删除 1-删除 0-未删除
   */
  @ApiModelProperty(value = "逻辑删除 1-删除 0-未删除")
  @NotNull(message = "逻辑删除 1-删除 0-未删除不能为空")
  @TableField("is_delete")
  @Excel(name = "逻辑删除 1-删除 0-未删除")
  private Integer isDelete;

  /**
   * 商户编号
   */
  @ApiModelProperty(value = "商户编号")
  @NotEmpty(message = "商户编号不能为空")
  @TableField(value = "tenant_code", condition = LIKE)
  @Excel(name = "商户编号")
  private String tenantCode;

  @Builder
  public SalesLevel(Long id, LocalDateTime updateTime, Long updateUser, LocalDateTime createTime,
      Long createUser,
      SalesLevelRuleDTO rule, BigDecimal indirectRate, BigDecimal directRate, Integer isDefault,
      Integer sort, String levelName, Integer isDelete, String tenantCode) {
    this.id = id;
    this.updateTime = updateTime;
    this.updateUser = updateUser;
    this.createTime = createTime;
    this.createUser = createUser;
    this.rule = rule;
    this.indirectRate = indirectRate;
    this.directRate = directRate;
    this.isDefault = isDefault;
    this.sort = sort;
    this.levelName = levelName;
    this.isDelete = isDelete;
    this.tenantCode = tenantCode;
  }

}
